package com.slot.faraohgoldview;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.view.View;

public class InfoPanel extends View {
	private Bitmap Info;
	private float scaleY, scaleX;
	private Paint paint;
	static final int SYMBOL_FIELDS = 24;
	static final int ALL_FIELDS = 28;
	static final int[] SYMBOL_PAY = {
		9000,2500,250,10,250,75,15,125,50,10,100,25,5,750,125,25,2,400,100,20,100,25,5,2,500,20,5,2
	};
	static final int[] FIELD_POSITION_X = {
		200,200,200,200,
		80,80,80,
		80,80,80,
		163,163,163,
		575,575,575,575,
		575,575,575,
		525,525,525,525,
		375,375,375,375
	};
	static final int[] FIELD_POSITION_Y = {
		23,40,57,74,
		100,120,140,
		262,281,300,
		380,400,420,
		126,143,160,177,
		300,320,340,
		390,408,425,442,
		258,277,295,314
	};
	private int[] tablePay = new int[ALL_FIELDS];

	public InfoPanel(Context context) {
		super(context);
		paint = new Paint();
		paint.setColor(Color.YELLOW);
		paint.setTextAlign(Paint.Align.CENTER);
		paint.setTypeface(Typeface.DEFAULT_BOLD);
		paint.setAntiAlias(true);
		Info=BitmapFactory.decodeResource(context.getResources(), R.drawable.infoscr);
		setTable(1,1);
	}
	
	@Override
    protected void onSizeChanged(int width, int height, int oldw, int oldh) {
		Info = Bitmap.createScaledBitmap(
				Info, width, height, true);
		scaleY = (float) height / 480;
		scaleX = (float) width / 640;
		paint.setTextSize(15 * scaleY);
	}
	
	@Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawBitmap(Info,0,0, null);
        for(int i=0;i<ALL_FIELDS;i++){
        	canvas.drawText("" + tablePay[i], FIELD_POSITION_X[i] * scaleX, (FIELD_POSITION_Y[i]+22) * scaleY, paint);
        }
	}
	
	public void setTable(int bet, int lines){
		for(int i=0;i<ALL_FIELDS;i++){
			tablePay[i]=SYMBOL_PAY[i]*bet;
			if(i>23) tablePay[i]*=lines;
		}
	}

}
